package com.my.declarative;

import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *  声明式事务管理
 *
 * @author: marshal
 * @date: 2023-05-24 15:41
 */
public class DeclarativeTransactionService {
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public void testTransaction() {
        update1();
        update2();
    }

    public Integer update1(){
        System.out.println("this is update1");
        return 1;
    }

    public Integer update2() {
        System.out.println("this is update2");
        return 2;
    }
}
